home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
401-425
/
417
/
mostcurrent
/
clearspace.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-14
|
4KB
|
206 lines
/* ClearSpace.c
*
* Programmed by: Peter A. Phelps 11/9/90
*
* See MostCurrent.doc for further info.
*
*/
#include <stdio.h>
#include <exec/types.h>
#define ASSEMBLY 0x00004000
#define BASIC 0x00080000
#define MODULA2 0x01000000
#define OTHER 0x20000000
#define ESC 27
void quit();
FILE *Index, *TmpIndex, *KeyNames, *NewKeyNames;
main()
{
char Tag[16], InChar;
int i, Line, Button = 0;
SHORT ThisFish = 0;
union
{
struct
{
ULONG BitMask;
SHORT FFDisk;
ULONG AbsAdr;
SHORT ContentsLength;
UBYTE Space___The_Final_Frontier;
} Entry;
struct
{
UBYTE Byte[13];
} ByteView;
} Record;
if((Index = fopen("index.old","r")) == (struct FILE *)NULL)
{
printf("index.old not found!\nSee MostCurrent.doc\n");
quit(0);
}
if((KeyNames = fopen("KeyNames.old","r")) == (struct FILE *)NULL)
{
printf("KeyNames.old not found!\nSee MostCurrent.doc\n");
quit(1);
}
for(i=0;i<29;i++)
while(getc(KeyNames) != '\n');
fgets(Tag,16,KeyNames);
if(strcmp(Tag,"Other code "))
{
printf("KeyNames.old has already been modified by this\n");
printf("program. Rename KeyNames.old to KeyNames, and\n");
printf("see MostCurrent.doc\n");
quit(2);
}
if((TmpIndex = fopen("index.tmp","x")) == (struct FILE *)NULL)
{
printf("index already exists!\nSee MostCurrent.doc\n");
quit(2);
}
if((NewKeyNames = fopen("KeyNames","x")) == (struct FILE *)NULL)
{
printf("KeyNames already exists!\nSee MostCurrent.doc\n");
quit(3);
}
printf("Please enter the number of the button you wish to give up\n");
printf("\n1) Assembly\n2) Basic\n3) Modula-2\n\n");
while(Button < 1 || Button > 3)
{
printf("Button Number (1-3): ");
scanf("%d",&Button);
}
fseek(KeyNames,0,0);
Line=0;
switch(Button)
{
case 1:
while(++Line<15)
{
InChar = '\0';
while(InChar != '\n')
putc((InChar = getc(KeyNames)),NewKeyNames);
}
Line--;
for(i=0;i<15;i++)
getc(KeyNames);
fprintf(NewKeyNames,"Basic ");
case 2:
while(++Line<20)
{
InChar = '\0';
while(InChar != '\n')
putc((InChar = getc(KeyNames)),NewKeyNames);
}
Line--;
for(i=0;i<15;i++)
getc(KeyNames);
fprintf(NewKeyNames,"Modula-2 ");
case 3:
while(++Line<25)
{
InChar = '\0';
while(InChar != '\n')
putc((InChar = getc(KeyNames)),NewKeyNames);
}
Line--;
for(i=0;i<15;i++)
getc(KeyNames);
fprintf(NewKeyNames,"Other code ");
break;
}
while(++Line<30)
{
InChar = '\0';
while(InChar != '\n')
putc((InChar = getc(KeyNames)),NewKeyNames);
}
for(i=0;i<15;i++)
getc(KeyNames);
fprintf(NewKeyNames,"Most Current ");
do
if((InChar = getc(KeyNames)) != EOF)
putc(InChar,NewKeyNames);
while(InChar != EOF);
fclose(NewKeyNames);
fclose(KeyNames);
printf("Revising keys on\n\n");
while((InChar = getc(Index)) != EOF)
{
for(i=0;i<13;i++)
{
Record.ByteView.Byte[i] = InChar;
InChar = getc(Index);
}
switch(Button)
{
case 1:
if(Record.Entry.BitMask & ASSEMBLY)
Record.Entry.BitMask |= OTHER;
Record.Entry.BitMask &= ~ASSEMBLY;
if(Record.Entry.BitMask & BASIC)
Record.Entry.BitMask |= ASSEMBLY;
case 2:
if(Button == 2 && Record.Entry.BitMask & BASIC)
Record.Entry.BitMask |= OTHER;
Record.Entry.BitMask &= ~BASIC;
if(Record.Entry.BitMask & MODULA2)
Record.Entry.BitMask |= BASIC;
case 3:
if(Button == 3 && Record.Entry.BitMask & MODULA2)
Record.Entry.BitMask |= OTHER;
Record.Entry.BitMask &= ~MODULA2;
if(Record.Entry.BitMask & OTHER)
Record.Entry.BitMask |= MODULA2;
break;
}
Record.Entry.BitMask &= ~OTHER;
for(i=0;i<13;i++)
putc(Record.ByteView.Byte[i],TmpIndex);
putc(0,TmpIndex);
if(Record.Entry.FFDisk != ThisFish)
printf("%c[AFish #%d\n",ESC,Record.Entry.FFDisk);
ThisFish = Record.Entry.FFDisk;
}
fclose(TmpIndex);
fclose(Index);
printf("Program has completed noramally.\n");
printf("Please run 'MostCurrent' now\n");
}
void quit(point)
{
switch(point)
{
case 3:
fclose(TmpIndex);
case 2:
fclose(KeyNames);
case 1:
fclose(Index);
case 0:
exit(FALSE);
}
}